package service

import (
	"awesomeTask/commom/locationHelper"
	awesomeTask "awesomeTask/config"
	"awesomeTask/system/echo"
	"awesomeTask/system/helper"
	"fmt"
)

type ConfigService struct {
}

func (ioc ConfigService) Register() {
	fmt.Println(helper.GetCurrentRunningPath() + "/FileSystem/log/")
	configPath := awesomeTask.GetConfigByKey("configDir").(string)
	awesomeTask.GetConfigByKey("database.master.host")
	awesomeTask.SetConfigByKey("workPath", helper.GetCurrentRunningPath())
	awesomeTask.SetConfigByKey("currentPath", helper.GetCurrentRunningPath())
	//运行源代码的路径
	awesomeTask.SetConfigByKey("projectPath", helper.GetCurrentRunningPath()+"/FileSystem/project/")
	awesomeTask.SetConfigByKey("logPath", helper.GetCurrentRunningPath()+"/FileSystem/log/")
	awesomeTask.MergeConfig(configPath + "/config-local.json")
	awesomeTask.SetConfigByKey("location", make(map[string]interface{}))
	awesomeTask.SetConfigByKey("fileSystem", helper.GetCurrentRunningPath()+"/FileSystem/")
	awesomeTask.SetConfigByKey("ddsPath", helper.GetCurrentRunningPath()+"/FileSystem/dds/")
	locationInfo, err := locationHelper.GetLocationInfo()
	if err == nil {
		awesomeTask.SetConfigByKey("location", locationInfo)
	}
	handleCommandLineSetToConfig()
	helper.PrintJson(awesomeTask.InitConfig())
}

/**
把命令提示行里面的参数写入的配置文件
*/
func handleCommandLineSetToConfig() {
	params := echo.GetCmdInputParams()
	for key, value := range params {
		awesomeTask.SetConfigByKey(key, value)
	}
}
func (ioc ConfigService) Boot() {

}
